function ranks = predict_genre(Xt_lyrics, Xq_lyrics, ...
                               Xt_audio, Xq_audio, ...
                               Yt)
% Returns the predicted rankings, given lyric and audio features.
%
% Usage:
%
%   RANKS = PREDICT_GENRE(XT_LYRICS, YT_LYRICS, XQ_LYRICS, ...
%                         XT_AUDIO, YT_AUDIO, XQ_AUDIO);
%
% This is the function that we will use for checkpoint evaluations and the
% final test. It takes a set of lyric and audio features and produces a
% ranking matrix as explained in the project overview. 
%
% This function SHOULD NOT DO ANY TRAINING. This code needs to run in under
% 5 minutes. Therefore, you should train your model BEFORE submission, save
% it in a .mat file, and load it here.

%% Predict based on Lyrics 

% k = 1; 
% 
% train_struct = knn_train(Xt_lyrics, Yt, k);
% scores = knn_test(train_struct, Xq_lyrics); 


% N = size(Xq_lyrics, 1);            % number of quiz examples
% N_train = size(Xt_lyrics, 1);      % number of training examples 
% %scores = zeros(N, 10);             % # examples by # classes (1 if an example is in that class)
% 
% % converting word counts to probabilities 
% Xt = bsxfun(@rdivide, Xt_lyrics, sum(Xt_lyrics, 2));
% Xq = bsxfun(@rdivide, Xq_lyrics, sum(Xq_lyrics, 2));
% 
% % quiz-training silimarities (quiz along row, training along col)
% D = kernel_intersection(Xt, Xq);
% 
% 
% % sort in descending order along rows 
% [~, D_sorted] = sort(D, 2, 'descend');                                
% 
% % converts N x M to NM x 1 after transpose --> examples to class labels
% D_classes = Yt( reshape( D_sorted', numel(D_sorted), 1 ) ); 
% 
% % convert back to N x M 
% D_classes = transpose ( reshape( D_classes, N_train, N ) ); 
% 
% % ranking the classes based on "first index" (most similar 
% % training example from that class)
% ranks = zeros(N, 10);
% 
% for i = 1:size(D_classes, 1)
%     [class_sort(:,1), class_sort(:,2)] = unique( D_classes(i,:), 'first' );
%     class_sort = sortrows(class_sort, 2); 
%     ranks(i, : ) = class_sort(:,1)'; 
% end 

%% Predict based on Audio 

load dt.mat
scores = dt_test_multi(dt, Xq_audio); 


%% 
ranks = get_ranks(scores);

end
